package com.eastfair.mobile.service.impl;

//import com.baomidou.dynamic.datasource.annotation.DS;
import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.home.api.BoothAcceptanceRecordFeign;
import com.eastfair.home.dto.BoothAcceptanceRecordDTO;
import com.eastfair.home.dto.BoothAcceptanceRecordQuery;
import com.eastfair.home.dto.SupervisionItemManagementQuery;
import com.eastfair.home.vo.BoothAcceptanceRecordVO;
import com.eastfair.home.vo.SupervisionItemQuestionVO;
import com.eastfair.mobile.service.MobileBoothAcceptanceRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author lyw
 * @Date 2022/9/13 14:09
 */
@Slf4j
@Service
//@DS("#thread.tenant")
public class MobileBoothAcceptanceRecordServiceImpl implements MobileBoothAcceptanceRecordService {

    @Resource
    private BoothAcceptanceRecordFeign boothAcceptanceRecordFeign;

    @Override
    public R<Boolean> saveBoothAcceptanceDetail(BoothAcceptanceRecordDTO dto) {
        try {
            R<Boolean> result = boothAcceptanceRecordFeign.saveBoothAcceptanceDetail(dto);
            if (!result.getIsSuccess()) {
                throw BizException.wrap(result.getCode(), result.getMsg());
            }
            return result;
        }catch (Exception e){
            throw e;
        }
    }

    @Override
    public R<List<BoothAcceptanceRecordVO>> getBoothAcceptanceRecord(BoothAcceptanceRecordQuery query) {
        R<List<BoothAcceptanceRecordVO>> result = boothAcceptanceRecordFeign.getBoothAcceptanceRecord(query);
        if (!result.getIsSuccess()) {
            throw BizException.wrap(result.getCode(), result.getMsg());
        }
        return result;
    }

    @Override
    public R<List<SupervisionItemQuestionVO>> queryQuestion(SupervisionItemManagementQuery query) {
        R<List<SupervisionItemQuestionVO>> result = boothAcceptanceRecordFeign.queryQuestion(query);
        if (!result.getIsSuccess()) {
            throw BizException.wrap(result.getCode(), result.getMsg());
        }
        return result;
    }
}
